<?php exit('404');?>
{include header}
<!-- ext.article-header($article) -->
<div class="content">
	<div class="title">文章列表</div>
	<!-- ext.article-menu-header($article) -->
	<div class="article-menu">
		<div class="article-menu-left">
			<!-- ext.article-menu-left-top($article) -->
			<div class="btn bg-red" onclick="del();">批量删除</div>
			<select name="tag" style="margin-left:10px;">
				{foreach $tagList as $tag => $count}
				<option value="{$tag}">{$tag}</option>
				{/foreach}
			</select>
			<div class="btn bg-blue" onclick="move();">移动到该分类</div>
			<!-- ext.article-menu-left-bottom($article) -->
		</div>
		<div class="article-menu-right">
			<!-- ext.article-menu-right-top($article) -->
			<a href="{url admin/article/create}" class="btn">创建文章</a>
			<!-- ext.article-menu-right-bottom($article) -->
		</div>
	</div>
	<!-- ext.article-menu-footer($article) -->
	{if $article.list}
	<div class="table table-hover nowrap">
		<table>
			<thead>
				<tr>
			    	<th>选择</th>
					<th style="width:100%;">标题</th>
					<th>时间</th>
					<th>分类</th>
					<th>浏览</th>
					<th>评论</th>
					<th>操作</th>
			    </tr>
			</thead>
			<tbody>
				{foreach $article.list}
				{{
					$item.icon = $item.top ? '▲' : ($item.private ? '▣' : '❖');
					$item.time = dates($item.time);
				}}
				<tr>
			    	<td><input type="checkbox" name="article" value="{$item.id}"/></td>
					<td><a href="{$item.url}" target="_blank">{$item.icon} {$item.title}</a></td>
					<td>{$item.time}</td>
					<td>{$item.tag.name}</td>
					<td>{$item.views}</td>
					<td>{$item.comments}</td>
					<td>
						<a href="{url admin/article/editor/$item.id}">编辑</a>
						<!-- ext.article-list-operate($item,$key) -->
					</td>
			    </tr>
			    {/foreach}
			</tbody>
		</table>
	</div>
	<div class="paging">{$article.paging}</div>
	{else}
	暂无数据
	{/if}
	<!-- ext.article-bottom($article) -->
</div>
<div class="sidebar">
	<!-- ext.article-sidebar-top($article) -->
	<div class="title">分类标签</div>
	<ul class="sidebar-tag">
		<li><a href="{url admin/article}">全部({$conf.article.count})</a></li>
		{foreach $tagList as $tag => $count}
		<li><a href="{url admin/article/tag/$tag}">{$tag}({$count})</a></li>
		{/foreach}
	</ul>
	<!-- ext.article-sidebar-bottom($article) -->
</div>
<!-- ext.article-footer($article) -->
<script>
	SX('tbody tr').click(i=>{SX('[name=article]')[i].click()});
	SX('[name=article]').click(()=>{SX.sp()});
	//批量删除
	function del(){
		var sel = [];
		SX('[name=article]').each(function(){
			if(this.checked){
				sel.push(this.value);
			}
		})
		if(!sel.length) return SX.pop('请选择文章');
		SX.alert({
			content:'确实要删除吗？删除不可恢复！',
			yes(){
				SX.ajax('{url admin/article/delete}',{'id[]':sel}).then(res=>{
					location.reload();
				})
			}
		})
	}
	//移动分类
	function move(){
		var sel = [];
		SX('[name=article]').each(function(){
			if(this.checked){
				sel.push(this.value);
			}
		})
		if(!sel.length) return SX.pop('请选择文章');
		SX.ajax('{url admin/article/move}',{'id[]':sel,tag:SX('[name=tag]')[0].value}).then(res=>{
			if(res.error){
				SX.pop(res.data);
			}else{
				location.reload();
			}
		})
	}
</script>
{include footer}